/**
 * 
 */
package com.gs.practice.thread.javathreads.ch02;

import java.util.Vector;

/**
 * @author Sabuj Das | sabuj.das@gmail.com
 *
 */
public class CharacterEventHandler {

	private Vector<CharacterListener> listeners = new Vector<>();
	
	public void addCharacterListener(CharacterListener listener){
		listeners.add(listener);
	}
	
	public void removeCharacterListener(CharacterListener listener){
		listeners.remove(listener);
	}
	
	public void fireNewCharacter(CharacterSource source, int character){
		CharacterEvent event = new CharacterEvent(source, character);
		for (CharacterListener listener : listeners) {
			listener.newCharacter(event);
		}
	}
}
